package main.java.memento.white_box;

/**
 * 白箱备忘录
 */
public class Demo {
    public static void main(String[] args) {
        System.out.println("前==========");
        GameRole gameRole = new GameRole();
        gameRole.initState();
        gameRole.stateDisplay();
        //备份状态

        RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.setRoleStateMemento(gameRole.saveState());

        System.out.println("后=============");
        gameRole.fight();
        gameRole.stateDisplay();

        System.out.println("恢复状态=========");
        gameRole.recoverState(roleStateCaretaker.getRoleStateMemento());
        gameRole.stateDisplay();
    }
}
